﻿//-----------------------------------------------------------------------
// <copyright file="Schedule.cs" company="FastNET Services">
//     Copyright (c) 2008-2009. All Rights Reserved.
// </copyright>
// <license>
//     GPLv2
// </license>
// <warranty>
//     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
//     BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
//     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
//     DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//     OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// </warranty>
//-----------------------------------------------------------------------
#region Usings
using System;
using FastNET.CleanAct.Common.Repository;
using FastNET.CleanAct.Common.Repository.Business;
using FastNET.CleanAct.Common.Repository.Interfaces.DataInterfaces.ManagementEngine;
using FastNET.CleanAct.Common.Repository.Interfaces.Factories;
using FastNET.CleanAct.Common.Repository.Interfaces.Repositories.ManagementEngine;

#endregion

namespace FastNET.CleanAct.Client.ManagerEngineBusiness.DataObjects
{
    /// <summary>
    /// Business Class representing a Schedule for the client
    /// </summary>
    public class Schedule : IdentityBusinessBase<IScheduleData, IScheduleRepository>
    {
        #region AutoLoaded Property Fields



        #endregion

        #region Public CTor/DTor

        /// <summary>
        /// Initializes a new instance of the Schedule class
        /// </summary>
        public Schedule()
            : this(new RepositoryFactory())
        {

        }

        /// <summary>
        /// Initializes a new instance of the Schedule class
        /// </summary>
        /// <param name="ID">Identity of the data to retrieve</param>
        public Schedule(Identity ID)
            : this(new RepositoryFactory(), ID)
        {
        }

        #endregion

        #region Internal CTor/DTor

        /// <summary>
        /// Initializes a new instance of the Schedule class
        /// </summary>
        /// <param name="factory">Factory for retrieving the Repository from</param>
        /// <param name="data">Data for backing the business object</param>
        /// <exception cref="ArgumentNullException">Thrown if Factory or Data are null</exception>
        internal Schedule(IRepositoryFactory factory, IScheduleData data)
            : base(factory, data)
        {
        }

        /// <summary>
        /// Initializes a new instance of the Schedule class
        /// </summary>
        /// <param name="factory">Factory for retrieving the Repository from</param>
        /// <exception cref="ArgumentNullException">Thrown if Factory is null</exception>
        internal Schedule(IRepositoryFactory factory)
            : base(factory)
        {
            Data.CreatedDate = DateTime.UtcNow;
            Data.ModifiedDate = DateTime.UtcNow;
        }

        /// <summary>
        /// Initializes a new instance of the Schedule class
        /// </summary>
        /// <param name="factory">Factory for retrieving the Repository from</param>
        /// <param name="ID">Identity of the data to retrieve</param>
        /// <exception cref="ArgumentNullException">Thrown if Factory is null</exception>
        internal Schedule(IRepositoryFactory factory, Identity ID)
            : base(factory, ID)
        {
        }

        #endregion

        #region Overrides of BusinessBase<IScheduleData,IScheduleRepository>

        /// <summary>
        /// Method to check whether or not the current object is valid
        /// </summary>
        /// <returns>Boolean based on the validity of the object</returns>
        public override bool IsValid()
        {
            return true;
        }

        #endregion

        #region Properties

        /// <summary>
        /// Gets or sets the template the schedule item is associated with
        /// </summary>
        public Identity TemplateID
        {
            get
            {
                return Data.TemplateID;
            }

            set
            {
                Data.TemplateID = value;
                Data.ModifiedDate = DateTime.UtcNow;
            }
        }

        /// <summary>
        /// Gets or sets the user description for the schedule
        /// </summary>
        public string Name
        {
            get
            {
                return Data.Name;
            }

            set
            {
                Data.Name = value;
                Data.ModifiedDate = DateTime.UtcNow;
            }
        }

        /// <summary>
        /// Gets or sets the value for the schedule component
        /// </summary>
        public string Value
        {
            get
            {
                return Data.Value;
            }

            set
            {
                Data.Value = value;
                Data.ModifiedDate = DateTime.UtcNow;
            }
        }

        /// <summary>
        /// Gets or sets whether or not the schedule is currently enabled
        /// </summary>
        public bool Enabled
        {
            get
            {
                return Data.Enabled;
            }

            set
            {
                Data.Enabled = value;
                Data.ModifiedDate = DateTime.UtcNow;
            }
        }

        /// <summary>
        /// Gets or sets the date the schedule was created
        /// </summary>
        public DateTime CreatedDate
        {
            get
            {
                return Data.CreatedDate;
            }
        }

        /// <summary>
        /// Gets or sets the date the schedule was last modified
        /// </summary>
        public DateTime ModifiedDate
        {
            get
            {
                return Data.ModifiedDate;
            }
        }

        #endregion
    }
}